<template>
  <div style="height:100%;width:100%;position:relative;">
    <div class="pagetop" ref="buttondiv">
      <table>
        <tr>
          <td>快速查询</td>
          <td>
            <el-input v-model="txtsearch" placeholder="报告单元名称|ID|代码|助记符" style="width:200px" clearable
              @keyup.enter.native='btnQuery'></el-input>
          </td>
          <td>检验科室:</td>
          <td>
            <rm-ddl-common v-model="labdeptval" clearable filterable :appendtobody="true" visible-change:true
              datatype="labdept" dataname="检验科室" width="180px" @change="deptchange($event)">
            </rm-ddl-common>
          </td>
          <td>检验工作组:</td>
          <td>
            <rm-ddl-common v-model="labgroupval" clearable filterable :appendtobody="true" visible-change:true
              datatype="labgroup" dataname="检验工作组" width="180px" @change="labgroupchange($event)"></rm-ddl-common>
          </td>
          <td :width="buttonWidth"></td>
          <td style="align:right">
            <el-button icon="el-icon-search" type="primary" @click="btnQuery(), isFirstLoading = false, UpdateArr = []"
              v-has="'PINQUERY'">查询</el-button>
          </td>
          <td style="align:right">
            <el-button style="align:right" @click="addRptUnit" icon="el-icon-plus">新增</el-button>
          </td>
          <td style="align:right">
            <el-button icon="el-icon-edit" @click="OpenDialog(2)" v-has="'PMODIFY'">修改</el-button>
          </td>
          <td style="align:right">
            <el-button icon="el-icon-delete" @click="OpenDialog(3)" v-has="'PDELETE'">删除</el-button>
          </td>

          <td style="align:right">
            <el-button @click="OpenDialog(10)">复制项目/选项复制</el-button>
          </td>
        </tr>
      </table>
    </div>
    <div class="pagecenter">
      <rm-layout-right splitcolor="#ffffff" :splitwidth="3" :fixsize="600" :minfixsize="200">
        <div ref="xTableDiv" style="height:100%; " id="Vxe-print">
          <vxe-table ref="xTable" height="auto" size="mini" :bLoading="bLoading" :data.sync="tableData"
            :select-config="{ reserve: true }" :sort-config="{ trigger: 'cell' }" show-header-overflow="tooltip"
            :keyboard-local-config="keyLocalConfig" show-overflow="tooltip" highlight-current-row highlight-hover-row
            highlight-hover-column resizable header-align="center" @current-change="CurrentChangeEvent" stripe border
            :row-class-name="rowClassName" :cell-class-name="cellClassName" width="auto">
            <vxe-table-column key="labgroup" field="labgroup" title="检验工作组" sortable width="100px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptunit" field="rptunitid" title="ID" sortable width="50px" align="center"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptunitno" field="rptunitno" title="单元代码" sortable width="100px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptunitname" field="rptunitname" title="报告单元名称" sortable width="150px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="reporttypename" field="reporttypename" title="业务类型" width="100px" show-overflow
              align="center" sortable></vxe-table-column>
            <vxe-table-column key="inuse" field="inuse" title="标志" sortable width="60px" show-overflow
              align="center"></vxe-table-column>
            <vxe-table-column key="rptcl_comm" field="rptcl_comm" title="报告单元说明" sortable width="150px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="performbyname" field="performbyname" title="默认执行科室" sortable width="150px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="resultclass" field="resultclass" title=" 相关结果归类" sortable width="100px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="seq" field="seq" title="序号" sortable width="50ox" show-overflow
              align="center"></vxe-table-column>
            <vxe-table-column key="notserviceprint" field="notserviceprint" title="服务台不参与打印" sortable width="120px"
              show-overflow align="center"></vxe-table-column>
            <vxe-table-column key="notselfprint" field="notselfprint" title="自助不打印" sortable width="80px" show-overflow
              align="center"></vxe-table-column>
            <vxe-table-column key="notscreendisplay" field="notscreendisplay" title="大屏不提醒" sortable width="70px"
              show-overflow align="center"></vxe-table-column>
            <vxe-table-column key="prereport" field="prereport" title="初步报告" sortable width="70px" show-overflow
              align="center"></vxe-table-column>
            <vxe-table-column key="notwebcombrpt" field="notwebcombrpt" title="Web综合报告不参与" sortable width="130px"
              show-overflow align="center"></vxe-table-column>
            <vxe-table-column key="rptcomm1" field="rptcomm1" title="报告备注1" sortable width="200px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptcomm2" field="rptcomm2" title="报告备注2" sortable width="200px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptcomm3" field="rptcomm3" title="报告备注3" sortable width="200px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptcomm4" field="rptcomm4" title="报告备注4" sortable width="200px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="rptcomm5" field="rptcomm5" title="报告备注5" sortable width="200px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="basecolor" field="basecolor" title="基本色" sortable width="120px" show-overflow>
              <template v-slot="{ row, rowIndex }">
                <div v-bind:style="{ background: '#' + ColorChange(row.basecolor) }" style="height:20px;width:120px "></div>
              </template>
            </vxe-table-column>
            <vxe-table-column key="billingmodename" field="billingmodename" title="默认计价模式" sortable width="150px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="input_code" field="input_code" title="助记符" sortable width="80px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="deptname" field="deptname" title="对应科室" sortable width="100px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="wardno" field="wardname" title="对应病区" sortable width="100px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="mergeprintseq" field="mergeprintseq" title="Weblis合并打印序列" sortable width="120px"
              show-overflow></vxe-table-column>
            <vxe-table-column key="autoprintquerydays" field="autoprintquerydays" title="自助打印查询天数" sortable width="120px"
              show-overflow></vxe-table-column>
          </vxe-table>
        </div>
        <template v-slot:fix>
          <el-form style="overflow:scroll;height:100%;" label-width="auto" type="border-card" ref="rptitem"
            :model="rptitem" @submit.native.prevent>
            <table style="padding:5px;border-collapse:separate; border-spacing:3px 4px;">
              <tr>
                <td>报告单元 ID:</td>
                <td colspan="5">
                  <el-input v-model="rptitem.rptunitid" :disabled="true"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="rptitem.notserviceprint" size="medium "
                    :disabled="true">&nbsp;&nbsp;</el-checkbox>不参与服务台打印
                </td>
              </tr>
              <tr>
                <td>检验工作组:</td>
                <td colspan="5">
                  <el-input v-model="rptitem.labgroupname" :disabled="true"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="rptitem.notselfprint" align="left" size="medium"
                    :disabled="true">&nbsp;&nbsp;</el-checkbox>不参与自助机打印
                </td>
              </tr>
              <tr>
                <td>报告单元代码:</td>
                <td colspan="5">
                  <el-input v-model="rptitem.rptunitno" :disabled="true"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="rptitem.notscreendisplay" align="center" size="medium"
                    :disabled="true">&nbsp;&nbsp;</el-checkbox>不参与门诊报告大屏提醒
                </td>
              </tr>
              <tr>
                <td>报告单元名称:</td>
                <td colspan="5">
                  <el-input v-model="rptitem.rptunitname" :disabled="true"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="rptitem.prereport" align="center" size="medium"
                    :disabled="true">&nbsp;&nbsp;</el-checkbox>初步报告(可查询,不可打印)
                </td>
              </tr>
              <tr style="height:26px">
                <td>在用标志:</td>
                <td colspan="5" style="background-color: #f4f4f4">
                  &nbsp;
                  <input class="inuseinput" v-model="rptitem.inuse" :disabled="true" v-if="rptitem.inuse == '在用'"
                    style="color: #000FFF;background-color: #f4f4f4" />
                  <input class="inuseinput" v-model="rptitem.inuse" :disabled="true" v-if="rptitem.inuse == '停用'"
                    style="color: red;background-color: #f4f4f4" />
                  <input class="inuseinput" v-model="rptitem.inuse" :disabled="true" v-if="rptitem.inuse == '禁用'"
                    style="color: #b3b3b3;background-color: #f4f4f4" />
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="rptitem.notwebcombrpt" align="center" size="medium"
                    :disabled="true">&nbsp;&nbsp;</el-checkbox>不参与Web综合报告打印
                </td>
              </tr>
              <tr style="height:26px;">
                <td>业务类型:</td>
                <td colspan="4" style="background-color: #f4f4f4">
                  &nbsp;
                  {{ rptitem.reporttypename }}
                </td>
                <td>序号:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.seq" :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td>对应科室:</td>
                <td colspan="4" style="background-color: #f4f4f4">
                  &nbsp;&nbsp;{{ rptitem.deptname }}
                </td>
                <td>对应病区:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.wardname" :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td>WEB合并打印序列:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.mergeprintseq" :disabled="true"></el-input>
                </td>
                <td>自助打印查询天数:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.autoprintquerydays" :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="font-color:red">默认执行科室:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.performbyname" :disabled="true"></el-input>
                </td>
                <td>助记符:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.input_code" :disabled="true"></el-input>
                </td>
              </tr>
              <tr style="height:26px">
                <td>默认计价模式:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.billingmodename" :disabled="true"></el-input>
                </td>
                <td>相关结果归类:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.resultclass" :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td>默认仪器大类:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.instrclass" :disabled="true"></el-input>
                </td>
                <td>单元基本色:</td>
                <td colspan="4" style="padding-left:5px;">
                  <div v-bind:style="{ background: rptitem.basecolor }" style=" height:20px;width:100px;"></div>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告单元说明:</td>
                <td colspan="4">
                  <el-input type="textarea" :rows="1" autosize maxlength="50" v-model="rptitem.rptcl_comm"
                    :disabled="true"></el-input>
                </td>
                <td>标本号前缀:</td>
                <td colspan="4">
                  <el-input v-model="rptitem.samplenohead" :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告备注1:</td>
                <td colspan="9">
                  <el-input type="textarea" :rows="1" maxlength="50" autosize show-word-limit v-model="rptitem.rptcomm1"
                    :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告备注2:</td>
                <td colspan="9">
                  <el-input type="textarea" :rows="1" maxlength="50" autosize show-word-limit v-model="rptitem.rptcomm2"
                    :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告备注3:</td>
                <td colspan="9">
                  <el-input type="textarea" :rows="1" maxlength="50" autosize show-word-limit v-model="rptitem.rptcomm3"
                    :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告备注4:</td>
                <td colspan="9">
                  <el-input type="textarea" :rows="1" maxlength="50" autosize show-word-limit v-model="rptitem.rptcomm4"
                    :disabled="true"></el-input>
                </td>
              </tr>
              <tr>
                <td style="vertical-align:top">报告备注5:</td>
                <td colspan="9">
                  <el-input type="textarea" :rows="1" maxlength="50" autosize show-word-limit v-model="rptitem.rptcomm5"
                    :disabled="true"></el-input>
                </td>
              </tr>
            </table>
          </el-form>
        </template>
      </rm-layout-right>
    </div>
    <div>
      <!-- 编辑弹窗 -->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="dialogTitleEdit"
        :visible.sync="dialogVisibleEdit" width="760px" height="450px">
        <div>
          <el-form ref="editform" :model="editRptunitItem" label-width="auto">
            <table style="padding:5px">
              <tr>
                <td>报告单元 ID</td>
                <td colspan="5">
                  <el-input v-model="editRptunitItem.rptunitid" :disabled="true"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="editRptunitItem.notserviceprint" align="center" size="medium"
                    @change="CheckBoxchange(1)" ref="editnotserviceprint"
                    @keyup.enter.native="EnterAutoFocus('editnotserviceprint')">不参与服务台打印</el-checkbox>
                </td>
              </tr>
              <tr>
                <td>
                  <font color="#F56C6C">检验工作组</font>
                </td>
                <td colspan="2">
                  <rm-ddl-common v-model="editRptunitItem.labgroupid" @change="editlabgroupid_change" ref="editlabgroupid"
                    :appendtobody="true" visible-change:true datatype="labgroup" dataname="检验工作组" width="100%"
                    @keyup.enter.native="EnterAutoFocus('editlabgroupid')"></rm-ddl-common>
                </td>
                <td colspan="2" style="display:none;">
                  <el-input v-model="editRptunitItem.labgroupname" :disabled="true"></el-input>
                </td>
                <td style="text-align:right">序号</td>
                <td colspan="2">
                  <el-input v-model="editRptunitItem.seq" ref="editseq"
                    @keyup.enter.native="EnterAutoFocus('editseq')"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="editRptunitItem.notselfprint" align="center" size="medium"
                    @change="CheckBoxchange(2)" ref="editnotselfprint"
                    @keyup.enter.native="EnterAutoFocus('editnotselfprint')">不参与自助机打印</el-checkbox>
                </td>
              </tr>
              <tr>
                <td>
                  <font color="#F56C6C">报告单元代码</font>
                </td>
                <td colspan="2">
                  <el-input placeholder="未填" v-model="editRptunitItem.rptunitno" ref="editrptunitno" style="width:200px"
                    clearable @keyup.enter.native="EnterAutoFocus('editrptunitno')"></el-input>
                </td>
                <td>标本号前缀</td>
                <td colspan="2">
                  <el-input placeholder="未填" v-model="editRptunitItem.samplenohead" style="width:150px" clearable
                    ref="editsamplenohead" @keyup.enter.native="EnterAutoFocus('editsamplenohead')"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="editRptunitItem.notscreendisplay" align="center" size="medium"
                    @change="CheckBoxchange(3)" ref="editnotscreendisplay"
                    @keyup.enter.native="EnterAutoFocus('editnotscreendisplay')">不参与门诊报告大屏提醒</el-checkbox>
                </td>
              </tr>
              <tr>
                <td>
                  <font color="#F56C6C">报告单元名称</font>
                </td>
                <td colspan="2">
                  <el-input placeholder="未填" v-model="editRptunitItem.rptunitname" style="width:200px"
                    @keyup.enter.native="EnterAutoFocus('editrptunitname')" ref="editrptunitname" @change="getInput_Code"
                    clearable></el-input>
                </td>
                <td>助记符</td>
                <td colspan="2">
                  <el-input placeholder="请填入缩写助记符" v-model="editRptunitItem.input_code" clearable style="width:150px"
                    ref="editinput_code" @keyup.enter.native="EnterAutoFocus('editinput_code')"></el-input>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="editRptunitItem.prereport" align="center" size="medium"
                    @change="CheckBoxchange(4)" ref="editprereport"
                    @keyup.enter.native="EnterAutoFocus('editprereport')">初步报告(可查询,不可打印)</el-checkbox>
                </td>
              </tr>
              <tr></tr>
              <tr style="height:15px">
                <td>
                  <font color="#F56C6C">在用标志</font>
                </td>
                <td colspan="5">
                  <el-radio-group v-model="editRptunitItem.inuse">
                    <el-radio ref="editinuse" @keyup.enter.native="EnterAutoFocus('editinuse')" :label="'1'">在用</el-radio>
                    <el-radio :label="'0'">停用</el-radio>
                    <el-radio :label="'9'">禁用</el-radio>
                  </el-radio-group>
                </td>
                <td colspan="4" style="text-align:left">
                  <el-checkbox v-model="editRptunitItem.notwebcombrpt" align="center" size="medium"
                    @change="CheckBoxchange(5)" ref="editnotwebcombrpt"
                    @keyup.enter.native="EnterAutoFocus('editnotwebcombrpt')">不参与Web综合报告打印</el-checkbox>
                </td>
              </tr>
              <tr style="height:26px">
                <td>
                  <font color="#F56C6C">业务类型</font>
                </td>
                <td colspan="9">
                  <el-radio-group v-model="editRptunitItem.reporttype">
                    <el-radio :label="'10'" ref="editreporttype"
                      @keyup.enter.native="EnterAutoFocus('editreporttype')">通用</el-radio>
                    <el-radio :label="'20'">细菌</el-radio>
                    <el-radio :label="'30'">图文</el-radio>
                    <el-radio :label="'40'">骨髓</el-radio>
                    <el-radio :label="'50'">PDF</el-radio>
                    <el-radio :label="'60'">基因</el-radio>
                    <el-radio :label="'90'">血库</el-radio>
                  </el-radio-group>
                </td>
              </tr>
              <tr>
                <td>对应科室</td>
                <td colspan="2">
                  <rm-ddl-common datatype="dept" dataname="科室" v-model="editRptunitItem.deptno" :appendtobody="true"
                    visible-change:true width="150px" ref="editdeptno" @keyup.enter.native="EnterAutoFocus('editdeptno')"
                    @change="editdept_change"></rm-ddl-common>
                </td>
                <td colspan="2" style="display:none;">
                  <el-input v-model="editRptunitItem.deptname"> </el-input>
                </td>
                <td>对应病区</td>
                <td colspan="2">
                  <rm-ddl-common datatype="ward" dataname="病区" v-model="editRptunitItem.wardno" :appendtobody="true"
                    visible-change:true width="150px" ref="editwardno" @keyup.enter.native="EnterAutoFocus('editwardno')"
                    @change="editward_change"></rm-ddl-common>
                </td>
                <td colspan="2" style="display:none;">
                  <el-input v-model="editRptunitItem.wardname"> </el-input>
                </td>
              </tr>
              <tr>
                <td>Web合并序列</td>
                <td colspan="2">
                  <el-input-number placeholder="未填" style="width:150px" v-model="editRptunitItem.mergeprintseq"
                    size="mini" :min="0" :max="999999" clearable ref="editmergeprintseq"
                    @keyup.enter.native="EnterAutoFocus('editmergeprintseq')"></el-input-number>
                </td>
                <td>自助打印查询天数</td>
                <td colspan="2">
                  <el-input-number placeholder="未填" size="mini" style="width:150px"
                    v-model="editRptunitItem.autoprintquerydays" :min="0" :max="9999" clearable
                    ref="editautoprintquerydays" @keyup.enter.native="
                      EnterAutoFocus('editautoprintquerydays')
                      "></el-input-number>
                </td>
              </tr>
              <tr>
                <td>报告单元说明</td>
                <td colspan="9">
                  <el-input placeholder="未填写报告单元说明" v-model="editRptunitItem.rptcl_comm" clearable ref="editrptcl_comm"
                    @keyup.enter.native="EnterAutoFocus('editrptcl_comm')">
                  </el-input>
                </td>
              </tr>
              <tr>
                <td style="font-color:red">默认执行科室</td>
                <td colspan="9">
                  <rm-ddl-common datatype="dept" dataname="科室" :appendtobody="true" visible-change:true
                    v-model="editRptunitItem.performby" ref="editperformby"
                    @keyup.enter.native="EnterAutoFocus('editperformby')" @change="editperformby_change"></rm-ddl-common>
                </td>
                <td style="display:none;" colspan="9">
                  <el-input v-model="editRptunitItem.performbyname"></el-input>
                </td>
              </tr>

              <tr style="height:26px">
                <td>
                  <font color="#F56C6C">默认计价模式</font>
                </td>
                <td colspan="9">
                  <el-radio-group v-model="editRptunitItem.billingmode">
                    <el-radio :label="'10'" ref="editbillingmode"
                      @keyup.enter.native="EnterAutoFocus('editbillingmode')">自动计价</el-radio>
                    <el-radio :label="'20'">手动计价</el-radio>
                    <el-radio :label="'30'">审核</el-radio>
                    <el-radio :label="'90'">不计价</el-radio>
                  </el-radio-group>
                </td>
              </tr>
              <tr style="height:15px">
                <td>默认仪器大类</td>
                <td colspan="2">
                  <rm-ddl-common @change="seccodechange" datatype="seccode" kindno="INSTRCLASS" dataname="仪器大类"
                    v-model="editRptunitItem.instrclass" :appendtobody="true" visible-change:true width="150px"
                    ref="editinstrclass" @keyup.enter.native="EnterAutoFocus('editinstrclass')"></rm-ddl-common>
                </td>
                <td>相关结果归类</td>
                <td colspan="2">
                  <el-autocomplete class="inline-input" v-model="state1" :fetch-suggestions="querySearch"
                    placeholder="请输入内容" @select="handleSelect" style="width:150px" ref="editstate1"
                    @keyup.enter.native="EnterAutoFocus('editstate1')"></el-autocomplete>
                </td>
                <td size="small">单元基本色</td>
                <td colspan="2">
                  <el-color-picker ref="editbasecolor" v-model="editRptunitItem.basecolor"
                    @keyup.enter.native="EnterAutoFocus('editbasecolor')"></el-color-picker>
                </td>
              </tr>
              <tr>
                <td>报告备注1</td>
                <td colspan="9">
                  <el-input show-overflow="tooltip" type="text" maxlength="100" show-word-limit placeholder="报告备注1待填"
                    v-model="editRptunitItem.rptcomm1" clearable ref="editrptcomm1"
                    @keyup.enter.native="EnterAutoFocus('editrptcomm1')"></el-input>
                </td>
              </tr>
              <tr>
                <td>报告备注2</td>
                <td colspan="9">
                  <el-input type="text" maxlength="100" show-word-limit placeholder="报告备注2待填"
                    v-model="editRptunitItem.rptcomm2" clearable ref="editrptcomm2"
                    @keyup.enter.native="EnterAutoFocus('editrptcomm2')"></el-input>
                </td>
              </tr>
              <tr>
                <td>报告备注3</td>
                <td colspan="9">
                  <el-input type="text" maxlength="100" show-word-limit placeholder="报告备注3待填"
                    v-model="editRptunitItem.rptcomm3" clearable ref="editrptcomm3"
                    @keyup.enter.native="EnterAutoFocus('editrptcomm3')"></el-input>
                </td>
              </tr>
              <tr>
                <td>报告备注4</td>
                <td colspan="9">
                  <el-input type="text" maxlength="100" show-word-limit placeholder="报告备注4待填"
                    v-model="editRptunitItem.rptcomm4" clearable ref="editrptcomm4"
                    @keyup.enter.native="EnterAutoFocus('editrptcomm4')"></el-input>
                </td>
              </tr>
              <tr>
                <td>报告备注5</td>
                <td colspan="9">
                  <el-input type="text" maxlength="100" show-word-limit placeholder="报告备注5待填"
                    v-model="editRptunitItem.rptcomm5" clearable ref="editrptcomm5"
                    @keyup.enter.native="EnterAutoFocus('editrptcomm5')"></el-input>
                </td>
              </tr>
            </table>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="btnSave"> 确 定</el-button>
          <el-button @click.native="dialogVisibleEdit = false" :autofocus="true">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <!-- 删除窗 -->
    <div>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" style="padding:5px"
        :title="dialogTitleDel" :visible.sync="dialogVisibleDel" width="500px">
        <span>确定删除该报告单元吗？</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="btnSave">确 定</el-button>
          <el-button @click="dialogVisibleDel = false" :autofocus="true">取 消</el-button>
        </span>
      </el-dialog>
    </div>
    <!-- 报告单元项目/选项复制 -->
    <div>
      <el-dialog v-el-drag-dialog style="padding:5px" :title="dialogTitle" :append-to-body="true"
        :close-on-click-modal="false" :visible.sync="dialogVisibleCopy" width="1100px" height="500px">
        <div style="width:100%;height:500px">
          <div style="width:65%;float:left;height:100%;">
            <table style="width: 100%; height:45px;font-size: 12px;" border="0">
              <td style="width:50px;">快速查询</td>
              <td>
                <el-input v-model="qcopy" placeholder="请输入以过滤" style="width:200px" clearable
                  @change='queryForCopyitem'></el-input>
              </td>
              <td style="width:50px">所属医院</td>
              <td>
                <rm-ddl-common v-model="qcopyhosp" filterable :appendtobody="true" visible-change:true datatype="areahosp"
                  dataname="所属医院" width="180px" @change="copychange($event)" :clearable="qcopyhospclr">
                </rm-ddl-common>
              </td>
              <td style="width:200px"></td>
            </table>
            <div style="height:calc( 100% - 50px)">
              <vxe-table ref="xTable_CopyItem" border resizable size="mini" :bLoading="bLoading" :data.sync="tableData3"
                :keyboard-config="{ isArrow: true }" show-header-overflow="tooltip" show-overflow="tooltip"
                highlight-current-row highlight-hover-row align="center" stripe height="100%"
                style=" border: 1px solid #ccc;" :select-config="{ reserve: true, showHeader: false, trigger: 'row' }">
                <vxe-table-column key="labgroupname" field="labgroupname" title="所属组" sortable width="100px"
                  show-overflow></vxe-table-column>
                <vxe-table-column type="selection" key="selection" field="selection" width="40"></vxe-table-column>
                <vxe-table-column key="rptunitname" field="rptunitname" title="报告单元名称" sortable width="140px"
                  show-overflow></vxe-table-column>
                <vxe-table-column key="rptunitno" field="rptunitno" title="单元代码" sortable width="70px"
                  show-overflow></vxe-table-column>
                <vxe-table-column key="rptunitid" field="rptunitid" title="单元ID" sortable width="70px"
                  show-overflow></vxe-table-column>
                <vxe-table-column key="hospitalname" field="hospitalname" title="所属医院" sortable width="230px"
                  show-overflow></vxe-table-column>
              </vxe-table>
            </div>
          </div>
          <div style="width:35%;float:left;height:100%;padding-left:15px; position:relative;">
            <div style="padding-left:10px">
              <el-button align="left" @click="CopyItem()">复制</el-button>
              <el-button align=" left" @click="dialogVisibleCopy = false" style="padding-left:15px">退出</el-button>
              <el-checkbox style="padding-left:30px;color:red; " v-model="override" true-label="1"
                false-label="0">强行覆盖数据</el-checkbox>
            </div>
            <table style=" width:80%;float:left;height:20%;">
              <tr>
                <td colspan="2">
                  <el-tag style="width:100%;height:45px;font-size:14px;text-align:left">当前单元:{{ this.orptunitname }} <br
                      style="padding-left:10px">请勾选要复制到的报告单元及复制的内容。
                  </el-tag>
                </td>
              </tr>
              <tr>
                <h3 align="left">复制内容</h3>
              </tr>
              <tr>
                <td style="text-align:left;" coslpan="5">
                  <el-checkbox align="left" size="medium" v-model="copytype1" true-label="1"
                    false-label="">报告单元选项(除报告单)</el-checkbox>
                </td>
                <td style="text-align:left;" coslpan="3">
                  <el-checkbox align="left" size="medium" v-model="copytype2" true-label="2"
                    false-label="">报告单元选项报告单设置</el-checkbox>
                </td>
              </tr>
              <tr>
                <td style="text-align:left;" coslpan="5">
                  <el-checkbox align="left" size="medium" v-model="copytype3" true-label="3"
                    false-label="">对应报告项目</el-checkbox>
                </td>
                <td style="text-align:left;" coslpan="3">
                  <el-checkbox align="left" size="medium" v-model="copytype4" true-label="4"
                    false-label="">对应输入模板</el-checkbox>
                </td>
              </tr>
              <tr>
                <td style="text-align:left;" coslpan="5">
                  <el-checkbox align="left" size="medium" v-model="copytype5" true-label="5"
                    false-label="">对应分单类别</el-checkbox>
                </td>
                <td style="text-align:left;" coslpan="3">
                  <el-checkbox align="left" size="medium" v-model="copytype6" true-label="6"
                    false-label="">对应标本类型</el-checkbox>
                </td>
              </tr>
              <tr>
                <td style="text-align:left;" coslpan="5">
                  <el-checkbox align="left" size="medium" v-model="copytype7" true-label="7"
                    false-label="">对应申请项目</el-checkbox>
                </td>
                <td style="text-align:left;" coslpan="3">
                  <el-checkbox align="center" size="medium" v-model="copytype8" true-label="8"
                    false-label="">对应备注</el-checkbox>
                </td>
              </tr>
            </table>

            <div style="overflow-x: auto; overflow-y: auto;  width:370px;float:left;height:calc(70% - 50px);">
              <template>
                <div v-for="msg in copylist" :key="msg.title" style="over-flow:auto">
                  <h3 style="color:red; font-size: 12px;">{{ msg }}</h3>
                </div>
              </template>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils"; //引入工具类
// import { exists } from "fs";
export default {
  name: "LIS130",
  data() {
    return {
      message: "",
      dataname: "检验工作组",
      rptunitid: "",
      torptunitid: "",
      rptunitno: "",
      billingmode: "",
      billingmodename: "",
      datatype: "labdept",
      color: "",
      labdeptval: "",
      labgroupval: "",
      input: "",
      isinuse: "", //在用右侧form判断标志，默认不勾
      txtsearch: "",
      tableData: [],
      tableData3: [],
      copylist: [],
      UpdateArr: [],
      selrow: [],
      bLoading: false,
      dialogVisibleEdit: false,
      dialogVisibleDel: false,
      dialogVisibleCopy: false,
      dialogTitle: "", // 弹窗标题
      dialogTitleEdit: "", //编辑弹窗
      dialogTitleDel: "", //删除弹框标题
      tempindex: 0,
      tempindex_copyitem: 0,
      buttonWidth: "",
      orptunitid: "",
      orptunitname: "", //获取源报告单元名称
      curselectrow: "",
      copytype: "",
      copytype1: "",
      copytype2: "",
      copytype3: "",
      copytype4: "",
      copytype5: "",
      copytype6: "",
      copytype7: "",
      copytype8: "",
      // torptunitid: "",
      logcontent: "",
      actionindex: "M",
      qcopy: "",
      qcopyhospclr: this.$ddldata.IsAreaMode ? false : true,
      qcopyhosp: this.$ddldata.IsAreaMode ? this.$tool.getSession(this.$tool.selectedhis) : "",
      loginutype: this.$tool.getSession(this.$tool.loginutype),
      override: 0,
      tempRowIndex: 0,
      resultclass2: [{ value: "临检血液" }, { value: "临检尿液" }, { value: "体液" }, { value: "生化" }, { value: "免疫" }, { value: "细菌" }, { value: "分子生物" }, { value: "其他" }, { value: "发光免疫" }, { value: "自身免疫" }, { value: "血常规" }, { value: "血流变" }, { value: "蛋白电泳" }, { value: "血气" }, { value: "便常规" }, { value: "凝血常规" }],
      state1: "",
      isFirstLoading: true,
      isCopyItemLoading: false,
      keyLocalConfig: {
        isArrow: true,
      },
      rptitem: {},
      editRptunitItem: {},
      oldformdata: {},
    };
  },
  created() {
    this.btnQuery();
  },
  updated() {
    if (this.isFirstLoading) {
      this.ComCallFun();
    }
    this.getButtonWidth();
  },
  mounted() { },
  methods: {
    ComCallFun() {
      let currentrow = "";
      if (this.dialogflag != 0) {
        //新增，修改，删除
        if (this.dialogflag == 3) {
          //如果是删除
          if (this.tempindex > 0) {
            var alld = this.$refs.xTable.tableData;
            let havedata = this.$refs.xTable.tableData;
            currentrow = this.$refs.xTable.getData(this.tempindex - 1);
          } else {
            currentrow = this.$refs.xTable.getData(0);
          }
        } else {
          //修改
          if (this.curselectrow && this.curselectrow != "") {
            this.$nextTick(() => {
              let row = this.curselectrow;
              var alld = this.$refs.xTable.tableData;
              for (var i = 0; i < alld.length; i++) {
                if (alld[i].rptunitid == row.rptunitid) {
                  this.tempindex = i;
                  break;
                }
              }
              currentrow = this.$refs.xTable.getData(this.tempindex);
            });
          } else {
            currentrow = this.$refs.xTable.getData(0);
          }
        }
      } else {
        //查询
        currentrow = this.$refs.xTable.getData(0);
        this.dialogflag = 2;
        this.curselectrow = currentrow;
      }
      this.$nextTick(() => {
        if (currentrow) {
          this.isFirstLoading = false;
          this.$refs.xTable.setCurrentRow(currentrow);
          this.CurrentRowChange(currentrow);
        }
      });
    },
    CheckBoxchange(flag) {
      if (flag == "1") {
        if (this.notserviceprint) {
          this.notserviceprint = "1";
        } else {
          this.notserviceprint = "0";
        }
      } else if (flag == "2") {
        if (this.notselfprint) {
          this.notselfprint = "1";
        } else {
          this.notselfprint = "0";
        }
      } else if (flag == "3") {
        if (this.notscreendisplay) {
          this.notscreendisplay = "1";
        } else {
          this.notscreendisplay = "0";
        }
      } else if (flag == "4") {
        if (this.prereport) {
          this.prereport = "1";
        } else {
          this.prereport = "0";
        }
      } else if (flag == "5") {
        if (this.notwebcombrpt) {
          this.notwebcombrpt = "1";
        } else {
          this.notwebcombrpt = "0";
        }
      }
    },
    queryForCopyitem() {
      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "querycopyitem",
            loginutype: this.loginutype,
            qcopy: this.qcopy,
            qcopyhosp: this.qcopyhosp,
          },
        })
        .then((res) => {
          this.isCopyItemLoading = true;
          this.tableData3 = res.Data;
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    detailQuery(row) {
      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "querydetail",
            rptunitid: this.rptunitid,
          },
        })
        .then((res) => {
          this.selrow = row;
          let detailDt = res[0];
          let tempcolor = detailDt.basecolor;
          let bgcolor = this.ColorChange(tempcolor);
          if (tempcolor == null || tempcolor == 0) {
            tempcolor = "FFFFFF";
          }
          let isNotServicePrint = detailDt.notserviceprint;
          if (!isNotServicePrint || isNotServicePrint != "1") {
            isNotServicePrint = false;
          } else {
            isNotServicePrint = true;
          }

          let isNotSelfPrint = detailDt.notselfprint;
          if (!isNotSelfPrint || isNotSelfPrint != "1") {
            isNotSelfPrint = false;
          } else {
            isNotSelfPrint = true;
          }
          let isNotScreenDisplay = detailDt.notscreendisplay;
          if (!isNotScreenDisplay || isNotScreenDisplay != "1") {
            isNotScreenDisplay = false;
          } else {
            isNotScreenDisplay = true;
          }
          let isPrereport = detailDt.prereport;
          if (!isPrereport || isPrereport != "1") {
            isPrereport = false;
          } else {
            isPrereport = true;
          }
          let isNotWebCombrpt = detailDt.notwebcombrpt;
          if (!isNotWebCombrpt || isNotWebCombrpt != "1") {
            isNotWebCombrpt = false;
          } else {
            isNotWebCombrpt = true;
          }

          if (detailDt.inuse == "1") {
            detailDt.inuse = "在用";
          } else if (detailDt.inuse == "0") {
            detailDt.inuse = "停用";
          } else if (detailDt.inuse == "9") {
            detailDt.inuse = "禁用";
          }
          this.rptitem = {
            rptunitid: detailDt.rptunitid, //报告单元ID
            labgroupid: detailDt.labgroupid,
            seq: detailDt.seq,
            labgroupname: detailDt.labgroupname, //所属工作组ID
            rptunitno: detailDt.rptunitno, //单元代码
            samplenohead: detailDt.samplenohead, //条码前缀
            rptunitname: detailDt.rptunitname, //报告单元名称
            performby: detailDt.performby, //默认执行科室代码
            performbyname: detailDt.performbyname,
            basecolor: "#" + bgcolor, //基本色
            input_code: detailDt.input_code, //助记符
            rptcomm1: detailDt.rptcomm1,
            rptcomm2: detailDt.rptcomm2,
            rptcomm3: detailDt.rptcomm3,
            rptcomm4: detailDt.rptcomm4,
            rptcomm5: detailDt.rptcomm5,
            reporttypename: detailDt.reporttypename, //业务类型
            billingmodename: detailDt.billingmodename, //默认计价模式
            resultclass: detailDt.resultclass, //相关结果归类
            inuse: detailDt.inuse, //在用标志
            rptcl_comm: detailDt.rptcl_comm, //报告单元说明
            instrclass: detailDt.instrclass, //默认仪器大类
            notserviceprint: isNotServicePrint, //不参与服务台打印
            notselfprint: isNotSelfPrint, //自助不打印
            notscreendisplay: isNotScreenDisplay, //大屏不提醒
            prereport: isPrereport, //初步报告
            notwebcombrpt: isNotWebCombrpt, //不参与Web综合打印
            deptno: detailDt.deptno,
            deptname: detailDt.deptname,
            wardno: detailDt.wardno,
            wardname: detailDt.wardname,
            mergeprintseq: detailDt.mergeprintseq,
            autoprintquerydays: detailDt.autoprintquerydays,
          };

          this.oldformdata = XEUtils.clone(detailDt, true);
          this.bLoading = false;
          // this.tempRowIndex = this.$refs.xTable.getRowIndex(this.bindMdlright);
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    updateQuery() {
      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "queryforupdate",
            rptunitid: this.rptunitid,
          },
        })
        .then((res) => {
          let detailDt = res[0];
          let tempcolor = detailDt.basecolor;
          if (tempcolor == null || tempcolor == 0) {
            tempcolor = "FFFFFF";
          }
          let bgcolor = this.ColorChange(tempcolor);
          let isNotServicePrint = detailDt.notserviceprint;
          if (isNotServicePrint == "" || isNotServicePrint == "0") {
            isNotServicePrint = false;
          } else {
            isNotServicePrint = true;
          }

          let isNotSelfPrint = detailDt.notselfprint;
          if (isNotSelfPrint == "" || isNotSelfPrint == "0") {
            isNotSelfPrint = false;
          } else {
            isNotSelfPrint = true;
          }
          let isNotScreenDisplay = detailDt.notscreendisplay;
          if (isNotScreenDisplay == "" || isNotScreenDisplay == "0") {
            isNotScreenDisplay = false;
          } else {
            isNotScreenDisplay = true;
          }
          let isPrereport = detailDt.prereport;
          if (isPrereport == "" || isPrereport == "0") {
            isPrereport = false;
          } else {
            isPrereport = true;
          }
          let isNotWebCombrpt = detailDt.notwebcombrpt;
          if (isNotWebCombrpt == "" || isNotWebCombrpt == "0") {
            isNotWebCombrpt = false;
          } else {
            isNotWebCombrpt = true;
          }
          this.editRptunitItem = {
            rptunitid: detailDt.rptunitid, //报告单元ID
            labgroupid: detailDt.labgroupid, //所属工作组ID
            seq: detailDt.seq,
            labgroupname: detailDt.labgroupname,
            rptunitno: detailDt.rptunitno, //单元代码
            samplenohead: detailDt.samplenohead, //条码前缀
            rptunitname: detailDt.rptunitname, //报告单元名称
            reporttype: detailDt.reporttype, //业务类型代码
            performby: detailDt.performby, //默认执行科室代码
            performbyname: detailDt.performbyname,
            basecolor: "#" + bgcolor, //基本色
            input_code: detailDt.input_code, //助记符
            rptcomm1: detailDt.rptcomm1,
            rptcomm2: detailDt.rptcomm2,
            rptcomm3: detailDt.rptcomm3,
            rptcomm4: detailDt.rptcomm4,
            rptcomm5: detailDt.rptcomm5,
            resultclass: detailDt.resultclass, //相关结果归类
            billingmode: detailDt.billingmode, //默认计价模式代码
            inuse: detailDt.inuse, //在用标志
            rptcl_comm: detailDt.rptcl_comm, //报告单元说明
            instrclass: detailDt.instrclass, //默认仪器大类
            notserviceprint: isNotServicePrint, //不参与服务台打印
            notselfprint: isNotSelfPrint, //自助不打印
            notscreendisplay: isNotScreenDisplay, //大屏不提醒
            prereport: isPrereport, //初步报告
            notwebcombrpt: isNotWebCombrpt, //不参与Web综合打印
            deptno: detailDt.deptno,
            wardno: detailDt.wardno,
            wardname: detailDt.wardname,
            mergeprintseq: detailDt.mergeprintseq,
            autoprintquerydays: detailDt.autoprintquerydays,
          };
          // this.editRptunitItem = this.detailDt;
          // this.editRptunitItem.basecolor='#' + bgcolor
          this.oldformdata = XEUtils.clone(detailDt, true);
          this.bLoading = false;
          this.tempRowIndex = this.$refs.xTable.getRowIndex(this.bindMdlright);
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
    //查询主表
    btnQuery() {
      this.bLoading = true;
      this.dialogflag = 0;
      this.orptunitid = "";
      this.orptunitname = "";
      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "query",
            qcode: this.txtsearch,
            labdeptcode: this.labdeptval,
            labgroupid: this.labgroupval,
          },
        })
        .then((res) => {
          if (res.Data.length) {
            this.isFirstLoading = true;
            this.tableData = res.Data;
            this.bLoading = false;
            res.Data.forEach((item) => {
              //在用状态转换
              if (item.inuse == "1") {
                item.inuse = "在用";
              } else if (item.inuse == "0") {
                item.inuse = "停用";
              } else if (item.inuse == "9") {
                item.inuse = "禁用";
              }
              //不参与服务台打印
              if (item.notserviceprint == "1") {
                item.notserviceprint = "√";
              } else {
                item.notserviceprint = "";
              }
              //不参与自助报告转换
              if (item.notselfprint == "1") {
                item.notselfprint = "√";
              } else {
                item.notselfprint = "";
              }
              //不参与门诊大屏转换
              if (item.notscreendisplay == "1") {
                item.notscreendisplay = "√";
              } else {
                item.notscreendisplay = "";
              }
              //初步报告，不可打印
              if (item.prereport == "1") {
                item.prereport = "√";
              } else {
                item.prereport = "";
              }
              //不参与Web综合打印
              if (item.notwebcombrpt == "1") {
                item.notwebcombrpt = "√";
              } else {
                item.notwebcombrpt = "";
              }
            });
            // this.detailQuery();
            this.bLoading = false;
          } else {
            this.tableData = [];
            this.bLoading = false;
          }
        })
        .catch((e) => {
          this.bLoading = false;
        });
    },
    querySearch(queryString, cb) {
      var resultclass2 = this.resultclass2;
      var results = queryString ? resultclass2.filter(this.createFilter(queryString)) : resultclass2;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (resultclass1) => {
        return resultclass1.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
      };
    },
    handleSelect(item) {
      this.editRptunitItem.resultclass = item.value;
    },

    CurrentChangeEvent({ row, rowIndex }) {
      this.CurrentRowChange(row, rowIndex);
      this.tempindex = rowIndex;
    },
    CurrentRowChange(row) {
      this.curselectrow = row;
      this.rptunitid = row.rptunitid;
      this.orptunitid = row.rptunitid;
      this.orptunitname = row.rptunitname;
      this.tempRowIndex = this.$refs.xTable.getRowIndex(row);
      this.converArgbToRgb(row.basecolor);
      this.detailQuery(row);
    },
    CurrentChangeEvent_CopyItem({ row, rowIndex }) {
      this.CurrentRowChange_CopyItem(row, rowIndex);
    },
    CurrentRowChange_CopyItem(row, rowIndex) {
      this.tempindex_copyitem = rowIndex;
      this.torptunitid = row.rptunitid;
    },
    //禁止新增报告单元
    addRptUnit() {
      this.$notify.info({
        title: "提示",
        message: "不可手工增加报告单元，请通过安装程序(仪器大类选择[其他]，仪器型号选择[手工]生成)",
        offset: 100,
      });
    },
    rowClassName({ row, rowIndex }) {
      if (row.inuse == "停用") {
        return "rm-alert";
      } else if (row.inuse == "禁用") {
        return "rm-disable";
      } else {
        ("");
      }
      if (this.UpdateArr.indexOf(row.rptunitid + "") > -1) {
        return "rm-modify";
      }
    },
    rptBasecolor(row, basecolor) {
      if (row.basecolor != "") {
        return "rptbasecolor";
      }
    },
    editlabgroupid_change(code, name) {
      this.editRptunitItem.labgroupname = name;
      this.editRptunitItem.labgroupid = code;
    },
    editperformby_change(code, name) {
      this.editRptunitItem.performbyname = name;
      this.editRptunitItem.performby = code;
    },
    editdept_change(code, name) {
      this.editRptunitItem.deptname = name;
      this.editRptunitItem.deptno = code;
    },
    editward_change(code, name) {
      this.editRptunitItem.wardname = name;
      this.editRptunitItem.wardno = code;
    },
    seccodechange(code, name) {
      this.editRptunitItem.instrclass = code;
      this.editRptunitItem.instrclassname = name;
    },
    deptchange(code) {
      this.labdeptval = code;
      this.btnQuery();
    },
    copychange(code) {
      this.qcopyhosp = code;
      this.queryForCopyitem();
    },
    labgroupchange(code) {
      this.dialogflag = 0;
      this.labgroupval = code;
      this.btnQuery();
    },
    //弹窗功能 flag 1新增(禁止) 2编辑 3删除 10复制单元项
    OpenDialog(flag) {
      this.dialogflag = flag; //选择功能
      if (flag == "2") {
        this.actionindex = "M";
        this.updateQuery();
        this.dialogTitleEdit = "报告单元编辑页面";
        this.state1 = this.rptitem.resultclass;
        this.dialogVisibleEdit = true;
        this.$nextTick(() => {
          this.$refs.editlabgroupid.$refs.ddlmainSelect.focus();
        });
      } else if (flag == "3") {
        this.actionindex = "D";
        this.updateQuery();
        this.dialogTitleDel = "报告单元删除";
        this.dialogVisibleDel = true;
      } else if (flag == "10") {
        if (this.orptunitid != "") {
          this.actionindex = "M";
          this.copylist = [];
          this.queryForCopyitem();
          this.copytype1 = "";
          this.copytype2 = "";
          this.copytype3 = "";
          this.copytype4 = "";
          this.copytype5 = "";
          this.copytype6 = "";
          this.copytype7 = "";
          this.copytype8 = "";
          this.copytype = "";
          this.override = "0";
          this.dialogTitle = "复制项目/选项复制";
          this.dialogVisibleCopy = true;
        } else {
          this.$confirm("请先选择被复制的报告单元", "提示", {
            cancelButtonText: "确定",
            type: "warning",
          });
        }
      }
    },
    //删除行
    delRow(rptunitid, rows) {
      rows.splice(rptunitid, 1);
    },
    getButtonWidth() {
      if (this.$refs.buttondiv) {
        this.buttonWidth = this.$refs.buttondiv.offsetWidth + "px";
      }
    },
    //回车事件
    EnterAutoFocus(element) {
      if (element == "editlabgroupid") {
        this.$refs.editlabgroupid.$refs.ddlmainSelect.blur();
        this.$refs.editseq.focus();
      } else if (element == "editseq") {
        this.$refs.editseq.blur();
        this.$refs.editrptunitno.focus();
      } else if (element == "editrptunitno") {
        this.$refs.editsamplenohead.focus();
      } else if (element == "editsamplenohead") {
        this.$refs.editrptunitname.focus();
      } else if (element == "editrptunitname") {
        this.$refs.editinput_code.focus();
      } else if (element == "editinput_code") {
        this.$refs.editinuse.$el.focus();
      } else if (element == "editinuse") {
        this.$refs.editreporttype.$el.focus();
      } else if (element == "editreporttype") {
        this.$refs.editdeptno.$refs.ddlmainSelect.focus();
      } else if (element == "editdeptno") {
        this.$refs.editdeptno.$refs.ddlmainSelect.blur();
        this.$refs.editwardno.$refs.ddlmainSelect.focus();
      } else if (element == "editwardno") {
        this.$refs.editwardno.$refs.ddlmainSelect.blur();
        this.$refs.editmergeprintseq.$refs.input.focus();
      } else if (element == "editmergeprintseq") {
        this.$refs.editautoprintquerydays.$refs.input.focus();
      } else if (element == "editautoprintquerydays") {
        this.$refs.editrptcl_comm.focus();
      } else if (element == "editrptcl_comm") {
        this.$refs.editperformby.$refs.ddlmainSelect.focus();
      } else if (element == "editperformby") {
        this.$refs.editbillingmode.$el.focus();
      } else if (element == "editbillingmode") {
        this.$refs.editperformby.$refs.ddlmainSelect.blur();
        this.$refs.editinstrclass.$refs.ddlmainSelect.focus();
      } else if (element == "editinstrclass") {
        this.$refs.editinstrclass.$refs.ddlmainSelect.blur();
        this.$refs.editstate1.focus();
      } else if (element == "editstate1") {
        this.$refs.editstate1.$el.blur();
        // this.$refs.editbasecolor.$refs.dropdown.focus();
        // } else if (element == "editbasecolor") {
        //     this.$refs.editbasecolor.$refs.dropdown.blur();
        this.$refs.editrptcomm1.focus();
      } else if (element == "editrptcomm1") {
        this.$refs.editrptcomm2.focus();
      } else if (element == "editrptcomm2") {
        this.$refs.editrptcomm3.focus();
      } else if (element == "editrptcomm3") {
        this.$refs.editrptcomm4.focus();
      } else if (element == "editrptcomm4") {
        this.$refs.editrptcomm5.focus();
      } else if (element == "editrptcomm5") {
        this.btnSave();
      }
    },
    //10转16
    ColorChange(color) {
      if (color != null) {
        var tempcolor = color.toString(16);
        var num = 6 - tempcolor.length;
        var result = tempcolor;
        if (num > 0) {
          for (let i = 0; i < num; i++) {
            result = "0" + result;
          }
        }
        var resultarr = result.split("");
        var r1 = resultarr[0];
        var r2 = resultarr[1];
        resultarr[0] = resultarr[4];
        resultarr[1] = resultarr[5];
        resultarr[4] = r1;
        resultarr[5] = r2;
        result = resultarr.join("");
        return result;
      } else {
        return "";
      }
    },
    //16转10
    colortrans(color) {
      var result = color;
      var resultarr = result.split("");
      var r1 = resultarr[0];
      var r2 = resultarr[1];
      resultarr[0] = resultarr[4];
      resultarr[1] = resultarr[5];
      resultarr[4] = r1;
      resultarr[5] = r2;
      if (resultarr.length > 0) {
        let k = parseInt(resultarr.join(""), 16);
        return k;
      } else {
        return "";
      }
    },
    // int转rgb
    converArgbToRgb(argb) {
      var rgb = [];
      rgb[2] = (argb & 0xff0000) >> 16;
      rgb[1] = (argb & 0xff00) >> 8;
      rgb[0] = argb & 0xff;
      return "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
    },
    cellClassName({ row, rowIndex, column, columnIndex }) {
      if (column.property === "basecolor") {
        if (row.basecolor != "") {
          let bgcolor = row.basecolor;
          let i = this.$refs.xTable.column;
          let j = {
            "background-color": this.converArgbToRgb(bgcolor),
          };
          return j;
        }
      }
    },
    getInput_Code() {
      this.editRptunitItem.input_code = this.$pub.CreateInputcode(this.editRptunitItem.rptunitname, this, 16);
    },
    btnSave() {
      let _this = this;
      if (this.editRptunitItem.labgroupid == "") {
        this.$message({
          message: "检验工作组不能为空！",
          type: "warning",
        });
        this.$refs.editlabgroupid.$refs.ddlmainSelect.focus();
        return false;
      }
      if (this.editRptunitItem.rptunitno == "") {
        this.$message({
          message: "报告单元代码不能为空！",
          type: "warning",
        });
        this.$refs.editrptunitno.focus();
        return false;
      }
      if (this.editRptunitItem.rptunitname == "") {
        this.$message({
          message: "报告单元名称不能为空！",
          type: "warning",
        });
        this.$refs.editrptunitname.focus();
        return false;
      }
      if (this.editRptunitItem.isinuse == "  ") {
        this.$message({
          message: "在用标志不能为空！",
          type: "warning",
        });
        return false;
      }
      if (this.editRptunitItem.reporttype == "  ") {
        this.$message({
          message: "业务类型不能为空！",
          type: "warning",
        });
        return false;
      }
      if (this.editRptunitItem.billingmode == "  ") {
        this.$message({
          message: "默认计价模式不能为空！",
          type: "warning",
        });
        return false;
      }
      if (this.dialogflag == 2) {
        this.dialogVisibleEdit = false;
      } else if (this.dialogflag == 3) {
        this.dialogVisibleDel = false;
      }
      let color = 0;
      let ks = this.editRptunitItem.basecolor;
      let t2 = ks.split("#");
      color = this.colortrans(t2[1]);
      let param = {
        labgroupid: this.editRptunitItem.labgroupid == null ? "" : this.editRptunitItem.labgroupid,
        seq: this.editRptunitItem.seq == null ? "" : this.editRptunitItem.seq,
        rptunitno: this.editRptunitItem.rptunitno == null ? "" : this.editRptunitItem.rptunitno,
        samplenohead: this.editRptunitItem.samplenohead == null ? "" : this.editRptunitItem.samplenohead,
        rptunitname: this.editRptunitItem.rptunitname == null ? "" : this.editRptunitItem.rptunitname,
        rptcl_comm: this.editRptunitItem.rptcl_comm == null ? "" : this.editRptunitItem.rptcl_comm,
        performby: this.editRptunitItem.performby == null ? "" : this.editRptunitItem.performby,
        resultclass: this.state1 == null ? "" : this.state1,
        input_code: this.editRptunitItem.input_code == null ? "" : this.editRptunitItem.input_code,
        instrclass: this.editRptunitItem.instrclass == null ? "" : this.editRptunitItem.instrclass,
        rptcomm1: this.editRptunitItem.rptcomm1 == null ? "" : this.editRptunitItem.rptcomm1,
        rptcomm2: this.editRptunitItem.rptcomm2 == null ? "" : this.editRptunitItem.rptcomm2,
        rptcomm3: this.editRptunitItem.rptcomm3 == null ? "" : this.editRptunitItem.rptcomm3,
        rptcomm4: this.editRptunitItem.rptcomm4 == null ? "" : this.editRptunitItem.rptcomm4,
        rptcomm5: this.editRptunitItem.rptcomm5 == null ? "" : this.editRptunitItem.rptcomm5,
        notserviceprint: this.editRptunitItem.notserviceprint == false ? 0 : 1,
        notselfprint: this.editRptunitItem.notselfprint == false ? 0 : 1,
        notscreendisplay: this.editRptunitItem.notscreendisplay == false ? 0 : 1,
        prereport: this.editRptunitItem.prereport == false ? 0 : 1,
        notwebcombrpt: this.editRptunitItem.notwebcombrpt == false ? 0 : 1,
        inuse: this.editRptunitItem.inuse,
        reporttype: this.editRptunitItem.reporttype,
        billingmode: this.editRptunitItem.billingmode,
        basecolor: color,
        rptunitid: this.editRptunitItem.rptunitid,
        deptno: this.editRptunitItem.deptno,
        wardno: this.editRptunitItem.wardno,
        mergeprintseq: this.editRptunitItem.mergeprintseq == "" ? "0" : this.editRptunitItem.mergeprintseq,
        autoprintquerydays: this.editRptunitItem.autoprintquerydays == "" ? "0" : this.editRptunitItem.autoprintquerydays,
      };

      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "save",
            utype: this.dialogflag,
            saveinfo: param,
            oldinfo: this.oldformdata,
          },
        })
        .then((response) => {
          if (response.errcode == "1") {
            this.$message({
              message: "操作成功！",
              type: "success",
            });
            if (this.actionindex == "M") {
              this.UpdateArr.push(response.keyid + "");
              this.SetToTable(this.editRptunitItem).then((row) => {
                this.hightLightRow(row);
              });
            }
            if (this.actionindex == "D") {
              var delrow = _this.$refs.xTable.getCurrentRow();
              if (delrow) {
                var alld = _this.$refs.xTable.getTableData().fullData;
                var rowindex = alld.indexOf(delrow);
                _this.$refs.xTable.remove(delrow);
                setTimeout(async () => {
                  let havedata = _this.$refs.xTable.tableData;
                  if (havedata.length > 0) {
                    if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                    let selectrow = havedata[rowindex];
                    _this.$refs.xTable.setCurrentRow(selectrow);
                    _this.rptunitid = selectrow.rptunitid;
                    _this.orptunitid = selectrow.orptunitid;
                    _this.orptunitname = selectrow.rptunitname;
                    _this.$refs.xTable.scrollToRow(selectrow);
                  }
                }, 5);
              }
            }
            this.actionindex = "M";
          } else {
            this.$message.error("保存失败:" + response.errmsg);
          }
        })
        .catch((e) => {
          this.dialogVisibleEdit = false;
        });
    },
    SetToTable(obj) {
      return new Promise((s, f) => {
        this.selrow.rptunitid = obj.rptunitid; //报告单元ID
        if (!!obj.labgroupname) this.selrow.labgroup = obj.labgroupname + "(" + obj.labgroupid + ")";
        this.selrow.seq = obj.seq;
        this.selrow.rptunitno = obj.rptunitno; //单元代码
        this.selrow.samplenohead = obj.samplenohead; //条码前缀
        this.selrow.rptunitname = obj.rptunitname; //报告单元名称
        if (!!obj.performbyname) this.selrow.performbyname = obj.performbyname;
        this.selrow.input_code = obj.input_code; //助记符
        this.selrow.rptcomm1 = obj.rptcomm1;
        this.selrow.rptcomm2 = obj.rptcomm2;
        this.selrow.rptcomm3 = obj.rptcomm3;
        this.selrow.rptcomm4 = obj.rptcomm4;
        this.selrow.rptcomm5 = obj.rptcomm5;
        this.selrow.reporttypename = obj.billingmode === "10" ? "通用报告" : obj.billingmode === "20" ? "细菌报告" : obj.billingmode === "30" ? "图文" : obj.billingmode === "40" ? "骨髓报告" : obj.billingmode === "50" ? "PDF报告" : obj.billingmode === "60" ? "基因报告" : obj.billingmode === "90" ? "血库报告" : "";
        this.selrow.billingmodename = obj.billingmode === "10" ? "自动计价" : obj.billingmode === "20" ? "手动计价" : obj.billingmode === "30" ? "审核" : obj.billingmode === "90" ? "不计价" : "";
        this.selrow.resultclass = obj.resultclass;
        this.selrow.inuse = obj.inuse === "1" ? "在用" : obj.inuse === "0" ? "停用" : obj.inuse === "9" ? "禁用" : "";
        this.selrow.rptcl_comm = obj.rptcl_comm;
        this.selrow.instrclass = obj.instrclass;
        this.selrow.notserviceprint = obj.notserviceprint === true ? "√" : obj.notserviceprint === false ? "" : "";
        this.selrow.notselfprint = obj.notselfprint === true ? "√" : obj.notselfprint === false ? "" : "";
        this.selrow.notscreendisplay = obj.notscreendisplay === true ? "√" : obj.notscreendisplay === false ? "" : "";
        this.selrow.prereport = obj.prereport === true ? "√" : obj.prereport === false ? "" : "";
        this.selrow.notwebcombrpt = obj.notwebcombrpt === true ? "√" : obj.notwebcombrpt === false ? "" : "";
        if (!!obj.deptname) this.selrow.deptname = obj.deptname;
        if (!!obj.wardname) this.selrow.wardname = obj.wardname;
        this.selrow.mergeprintseq = obj.mergeprintseq;
        this.selrow.autoprintquerydays = obj.autoprintquerydays;

        s(this.selrow);
        return;
      });
    },
    async hightLightRow(row) {
      if (!!row) {
        this.$refs.xTable.setCurrentRow(row);
        await this.detailQuery(row);
      } else {
        this.$refs.xTable.setCurrentRow(null);
        this.detailDt = {};
        this.oldformdata = {};
      }
    },
    CopyItem() {
      this.copylist = [];
      var selectRows = this.$refs.xTable_CopyItem.getSelectRecords();
      this.torptunitid = "";
      this.copytype = "";
      if (selectRows) {
        var targetInstrIds = [];
        for (let index in selectRows) {
          let item = {
            rptunitid: selectRows[index].rptunitid,
          };
          targetInstrIds[index] = item;
          this.torptunitid += targetInstrIds[index].rptunitid + ",";
        }
      } else {
        return;
      }
      if (this.copytype1 != "") {
        this.copytype += this.copytype1 + ",";
      }
      if (this.copytype2 != "") {
        this.copytype += this.copytype2 + ",";
      }
      if (this.copytype3 != "") {
        this.copytype += this.copytype3 + ",";
      }
      if (this.copytype4 != "") {
        this.copytype += this.copytype4 + ",";
      }
      if (this.copytype5 != "") {
        this.copytype += this.copytype5 + ",";
      }
      if (this.copytype6 != "") {
        this.copytype += this.copytype6 + ",";
      }
      if (this.copytype7 != "") {
        this.copytype += this.copytype7 + ",";
      }
      if (this.copytype8 != "") {
        this.copytype += this.copytype8 + ",";
      }
      this.$tool
        .request({
          url: "LIS/LIS1/LIS130",
          method: "post",
          data: {
            action: "copyitem",
            orirptunitid: this.orptunitid,
            torptunitid: this.torptunitid,
            copytype: this.copytype,
            override: this.override,
          },
        })
        .then((res) => {
          this.copytype = "";
          this.logcontent = res.execinfo;
          for (let i = 0; i < res.execinfo.length; i++) {
            let msg = res.execinfo[i].errmsg;
            this.copylist.push(msg);
          }
        })
        .catch((e) => {
          console.log("error", e);
        });
    },
  },
};
</script>

<style scoped>.pagetop {
  width: 100%;
  height: 36px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-align: center;
  position: absolute;
  z-index: 99;
  border: 1px solid #ccc;
}

.pagecenter {
  position: absolute;
  top: 41px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 605px;
  overflow: auto;
}

.middle-right {
  position: absolute;
  height: 100%;
  top: 0px;
  bottom: 0px;
  width: 600px;
  right: 0px;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}

table tr td:nth-child(even) {
  text-align: left;
}

table tr td:nth-child(1) {
  width: 80px;
}

table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}

td {
  padding: 0 3 px;
  border-spacing: 0px;
}

.inuseinput {
  font-weight: 900;
  border: 0px;
  background-color: #ffffff;
}

::v-deep tr.vxe-body--row.row--current {
  color: #000000;
  font-weight: bold;
}

::v-deep .el-dialog__body {
  padding-top: 10px !important;
  padding-bottom: 5px !important;
}

::v-deep .el-input.is-disabled .el-input__inner {
  color: #000000;
  border: 0px;
  padding: 0 5px;
  cursor: default;
}

::v-deep .el-textarea.is-disabled .el-textarea__inner {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #000000;
  padding: 5px;
  cursor: default;
}

::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #000000;
  cursor: default;
}

::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  cursor: default;
}

::v-deep .el-checkbox__input.is-disabled+span.el-checkbox__label {
  color: #c0c4cc;
  cursor: not-allowed;
  cursor: default;
}</style>
